<?php

/*
  Action	$2

  +1 Card; +1 Action
  You may discard a card; if you do, +1 Action.
  You may discard a card; if you do, +1 Buy.

 */

class Hamlet extends Card implements iAction, iKingdom, iCornucopia {

    public function __construct() {
        parent::__construct("Hamlet", 2);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 Card",
            "+1 Action",
            "You may discard a card; if you do, +1 Action",
            "You may discard a card; if you do, +1 Buy.");
    }
    
    public function play(Game $game, $isRealCard) {

        $drawed_cards = $game->drawCards(1);
        $game->addActions(1);
         ScreenDisplay::addScreenMessage($game, true, "get +1 action  and draw " . nicePrint($drawed_cards), "get +1 action and draws " . sizeof($drawed_cards) . " cards");


        $card_options = $game->getPlayHand();
		$card_options = getUniqueCards($card_options);
        if (sizeof($card_options) > 0) {
            $card_options[] = new Option('1', "None");

            $output = MySocket::GetUserReply($game, Input_ChooseOne, $card_options, 1, 1, null, "Choose a card to discard for +1 action");

            $card_name = $output[0];
            if ($card_name != 'None') {
                $card = $game->moveCardFromPileToPile($card_name, PlayHand, DiscardPile);
                $game->addActions(1);
                 ScreenDisplay::addScreenMessage($game, true, "discard " . nicePrint($card). " and get +1 action", "discards 1 card and get +1 action");
            }
        }

        $card_options = $game->getPlayHand();
		$card_options = getUniqueCards($card_options);
        if (sizeof($card_options) > 0) {
            $card_options[] = new Option('1', "None");

            $output = MySocket::GetUserReply($game, Input_ChooseOne, $card_options, 1, 1, null, "Choose a card to discard for +1 buy");
            $card_name = $output[0];
            if ($card_name != 'None') {
                $card = $game->moveCardFromPileToPile($card_name, PlayHand, DiscardPile);
                $game->addBuys(1);
                 ScreenDisplay::addScreenMessage($game, true, "discard " . nicePrint($card). " and get +1 buy", "discards 1 card and get +1 buy");
            }
        }
        $game->cardActionFinished();
        return true;
    }

}

?>